Pour cette deuxième séance, nous allons apprendre à utiliser un planifateur d’itinéraire sur R afin de calculer des isochrones autour de chaque supermarché et ainsi pouvoir identifier les zones de chalandises.
Une première information simple à obtenir mais très informative peut être obtenue en traçant des courbes d’isodistances autour de chaque supermarchés. On peut ainsi indentifier les zones non-deserviés.
télécharger le package en .zip en cliquant sur ce lien
https://cran.r-project.org/src/contrib/Archive/opentripplanner/opentripplanner_0.4.0.tar.gz
Et installer Java 8 sur votre ordinateur:
https://www.java.com/fr/download/
setwd("C:/Users/boufarsi/Documents/thèse/Enseignement/Geomarketing/New/")
Avis : The working directory was changed to C:/Users/boufarsi/Documents/thèse/Enseignement/Geomarketing/New inside a notebook chunk. The working directory will be reset when the chunk is finished running. Use the knitr root.dir option in the setup chunk to change the working directory for notebook chunks.
pacman::p_load(dplyr, ggplot2, sf,readr,readxl,tmap,tmaptools)
#installer le package opentripplaner (en modifiant le chemin d'acces)
install.packages("C:/Users/boufarsi/Documents/thèse/Enseignement/Geomarketing/New/opentripplanner_0.4.0.tar.gz", repos = NULL, type = "source")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:
https://cran.rstudio.com/bin/windows/Rtools/
Warning in install.packages :
le package ‘opentripplanner’ est en cours d'utilisation et ne sera pas installé
library(opentripplanner)
iris_grenoble<-st_read("iris_grenoble.gpkg")
Reading layer `iris_grenoble' from data source `C:\Users\boufarsi\Documents\thèse\Enseignement\Geomarketing\New\iris_grenoble.gpkg' using driver `GPKG'
Simple feature collection with 70 features and 36 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: 5.678578 ymin: 45.15415 xmax: 5.753078 ymax: 45.21432
Geodetic CRS: WGS 84
#vérifiez bien que vous avez la derniere version du fichier, avec 22 lignes (22 points de vente)
sirene_grenoble<-st_read("sirene_grenoble.gpkg")
Reading layer `sirene_grenoble' from data source `C:\Users\boufarsi\Documents\thèse\Enseignement\Geomarketing\New\sirene_grenoble.gpkg' using driver `GPKG'
Simple feature collection with 21 features and 106 fields
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 5.70661 ymin: 45.16637 xmax: 5.744077 ymax: 45.20106
Geodetic CRS: WGS 84
st_crs(sirene_grenoble) #l'unité est le mètre
Coordinate Reference System:
User input: WGS 84
wkt:
GEOGCRS["WGS 84",
ENSEMBLE["World Geodetic System 1984 ensemble",
MEMBER["World Geodetic System 1984 (Transit)"],
MEMBER["World Geodetic System 1984 (G730)"],
MEMBER["World Geodetic System 1984 (G873)"],
MEMBER["World Geodetic System 1984 (G1150)"],
MEMBER["World Geodetic System 1984 (G1674)"],
MEMBER["World Geodetic System 1984 (G1762)"],
MEMBER["World Geodetic System 1984 (G2139)"],
ELLIPSOID["WGS 84",6378137,298.257223563,
LENGTHUNIT["metre",1]],
ENSEMBLEACCURACY[2.0]],
PRIMEM["Greenwich",0,
ANGLEUNIT["degree",0.0174532925199433]],
CS[ellipsoidal,2],
AXIS["geodetic latitude (Lat)",north,
ORDER[1],
ANGLEUNIT["degree",0.0174532925199433]],
AXIS["geodetic longitude (Lon)",east,
ORDER[2],
ANGLEUNIT["degree",0.0174532925199433]],
USAGE[
SCOPE["Horizontal component of 3D system."],
AREA["World."],
BBOX[-90,-180,90,180]],
ID["EPSG",4326]]
buffer<-st_buffer(sirene_grenoble,500) #200m isodistance
tmap_mode("view")
tm_shape(iris_grenoble) +tm_text(text = "iris_name",size=0.8)+
tm_polygons("Pop_15_64", alpha=0.5,
style="pretty", id="iris_name",
title="Population (15-64 ans)")+
tm_shape(buffer)+tm_borders("chartreuse3",lwd=3)+
tm_shape(sirene_grenoble)+
tm_dots("enseigne1et",legend.show = TRUE,title="Enseigne",id="enseigne1et",popup.vars="trancheeffe.2",alpha=0.3)+
tm_layout(legend.outside = TRUE)
tm_shape(iris_grenoble) +tm_text(text = "iris_name",size=0.8)+
tm_polygons("Pop_15_64", alpha=0.5,
style="pretty", id="iris_name",
title="Population (15-64 ans)")+
tm_shape(buffer)+tm_polygons("enseigne1et",legend.show = FALSE,id="enseigne1et",alpha=0.5)+
tm_shape(sirene_grenoble)+
tm_dots("enseigne1et",legend.show = TRUE,title="Enseigne",id="enseigne1et",popup.vars="trancheeffe.2",alpha=0.8)+
tm_layout(legend.outside = TRUE)
NA
Un dossier & un sous-dossier specifiques à créer dans votre R working directory > OTP > graphs > default
Des données sur le réseau de transport GTFS (General Transit Feed Specification) à déposer dans OTP > graphs > default
Un fond de carte openstreetmap à déposer dans OTP > graphs > default
knitr::include_graphics("C:/Users/boufarsi/Documents/thèse/Enseignement/Geomarketing/New/gtfs.png")